package cn.cs.service;

import cn.cs.mapper.CsOrgMapper;
import cn.cs.mapper.CsRoleMapper;
import cn.cs.pojo.CsMenuRole;
import cn.cs.pojo.CsOrg;
import cn.cs.pojo.CsRole;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@RestController
public class CsRoleService {

    @Resource
    private CsRoleMapper csRoleMapper;

    @RequestMapping(value = "/getCsRoleById", method = RequestMethod.POST)
    public CsRole getCsRoleById(@RequestParam("id") Long id) throws Exception{
        return csRoleMapper.getCsRoleById(id);
    }

    @RequestMapping(value = "/getCsRoleListByMap", method = RequestMethod.POST)
    public List<CsRole> getCsRoleListByMap(@RequestBody Map<String, Object> param) throws Exception{
        return csRoleMapper.getCsRoleListByMap(param);
    }

    @RequestMapping(value = "/getCsRoleCountByMap", method = RequestMethod.POST)
    public Integer getCsRoleCountByMap(@RequestBody Map<String, Object> param) throws Exception{
        return csRoleMapper.getCsRoleCountByMap(param);
    }

    @RequestMapping(value = "/addCsRole", method = RequestMethod.POST)
    public Integer addCsRole(@RequestBody CsRole csRole) throws Exception{
        return csRoleMapper.insertCsRole(csRole);
    }

    @RequestMapping(value = "/modifyCsRole", method = RequestMethod.POST)
    public Integer modifyCsRole(@RequestBody CsRole csRole) throws Exception{
        return csRoleMapper.updateCsRole(csRole);
    }

    @RequestMapping(value = "/deleteCsRoleById", method = RequestMethod.POST)
    public Integer deleteCsRoleById(@RequestParam("id") String id) throws Exception{
        return csRoleMapper.deleteCsRoleById(id);
    }

    @RequestMapping(value = "/insertRoleMenusBatch", method = RequestMethod.POST)
    public Integer insertRoleMenusBatch(@RequestBody List<CsMenuRole> list, @RequestParam("role_id") String role_id){
        return csRoleMapper.insertRoleMenusBatch(list, role_id);
    }

}
